import http from '../utils/http'
import type { UserInfo } from '../model/user'

//注册
export const userRegister = (username:string,password:string)=>{
	return http.post('/users',{
		username,
		password
	})
}

//登录
export const userLogin = (username:string,password:string)=>{
	return http.post('/login',{
		username,
		password
	})
}

//账号信息更新
type UData = 'avatar'|'phone'|'name'
export const userUpdate = (objectId:string,session:string,userData:Partial<Pick<UserInfo,UData>>)=>{
	return http.put(`/users/${objectId}`,userData,{
		header:{
			"X-LC-Session":session  //个别网络请求，携带额外的配置
		}
	})
}